package com.example.lotterysystem.dao.mapper;

import com.example.lotterysystem.dao.dataobject.ActivityDO;
import com.example.lotterysystem.dao.dataobject.PrizeDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author xuejiao
 * Data 2025/5/3 22:47
 */
@Mapper
public interface ActivityMapper {

    @Insert("insert into lottery_system.activity (activity_name, description, status) VALUES " +
            "(#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id", keyColumn = "id")
    int insert(ActivityDO activityDO);


    @Select("select count(1) from lottery_system.activity")
    int count();

    @Select("select * from lottery_system.activity order by id desc limit #{offset}, #{pageSize}")
    List<ActivityDO> selectActivityList(@Param("offset") Integer offset,
                                  @Param("pageSize") Integer pageSize);

    @Select("select * from lottery_system.activity where id = #{id}")
    ActivityDO selectById(@Param("id") Long id);

    @Update("update lottery_system.activity set status = #{status} where id = #{id}")
    void updateStatus(@Param("id") Long id, @Param("status") String status);
}
